/*
Program creates an in-district tuition indicator for community college students for subgroup analysis.
Roughly 0.65 students enroll as in-district students or get super cheap tuition costs.
Manski (Econ of Education Review, 1990) asserts theoretically that high college dropout rates
can be explained by lower direct costs inducing students with weak academic preparation to
undertake the "college experiment".

We are creating a low-direct cost subgroup to assess whether or not remediation can improve their
college and labor market outcomes. By undertaking this and finding none or little effect, then our results would be more likely to be
generalizable to other states, like California that have extremely low college costs.
*/

clear
#delimit;
set mem 1g ;
set more off;

global d1="${col_remediation}program/program_paco/publication/"; 
do ${d1}do/top_program.do; 
cap mkdir ${d1}data/new/; 
 
log using "${d1}log/tuitionsubgroup.log", replace;

forvalues year = 192/200  {;
   forvalues sem = 1/4 {;
         display "JR Report 1: Year = `year' and Semester = `sem'";
         use altpid school tutstat using "${nh_data}HigherEd/Report1/Junior/D1jr`year'_`sem'.dta", clear;
		 duplicates drop altpid school, force;
		 /*  restricts JR college student report to first observation  for person-college combinations */
		 save "${d1}data/new/jr_rep1_`year'_`sem'.dta", replace;
						};
}; /*   closing loop   */

forvalues yr = 192/200 {;
       forvalues sem = 1/4 {;
			/*  keep observations for  specific year-semester combination at JR colleges  */
			use if (tspyr==`yr' & firstsem==`sem' & sr==0) using "${d1}data/tasp192_200_withall_tmp.dta", clear;
			merge altpid school using "${d1}data/new/jr_rep1_`yr'_`sem'.dta", nokeep sort; *  check to see if dates check out ;
			tab _merge;
			drop _merge;
			display "JR Report 1: Year = `yr' and Semester = `sem'";
			gen indist=tutstat==1;
			label var indist "Attend JR college in-district 0/1"; 
			save "${d1}data/new/tasp_jr_tuition_`yr'_`sem'.dta", replace;
							};
};     /* closing loop */


/* stack JR college TASP files */
forvalues yr = 192/200 	{;
		forvalues sem = 1/4 {;

			if (`yr'==192 & `sem'==1) {;
				use "${d1}data/new/tasp_jr_tuition_192_1.dta", clear;
										};
			else {;
				append using "${d1}data/new/tasp_jr_tuition_`yr'_`sem'.dta";
				};
							};
		};  /*  close loop  */
save "${d1}data/new/tasp_jr_tuition_192_200.dta", replace;

log close;